package com.yu.footballpromotionliveadmin.controller;

import com.yu.footballpromotionliveadmin.dto.DTO;
import com.yu.footballpromotionliveadmin.page.PageInfo;
import com.yu.footballpromotionliveadmin.pojo.EventRecords;
import com.yu.footballpromotionliveadmin.pojo.LiveBroadcasAdministrator;
import com.yu.footballpromotionliveadmin.service.LiveBroadcasAdministratorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
public class LiveBroadcasAdministratorController {


    @Autowired
    LiveBroadcasAdministratorService liveBroadcasAdministratorService;

    @GetMapping("/admin")
    public DTO<LiveBroadcasAdministrator> getAllLiveAdmin() throws Exception {

        return liveBroadcasAdministratorService.getAllLiveBroadcasAdministrators();
    }

    @GetMapping("/getAdmin/{lbano}")
    public DTO<LiveBroadcasAdministrator> getLiveAdminById(@PathVariable("lbano") String lbano) throws Exception {

        return liveBroadcasAdministratorService.getLiveBroadcasAdministratorById(lbano);
    }


    @PostMapping("/admin")
    public DTO<LiveBroadcasAdministrator> getLiveAdminById(@RequestBody LiveBroadcasAdministrator liveBroadcasAdministrator) throws Exception {
        System.out.println(liveBroadcasAdministrator+"111");
        return liveBroadcasAdministratorService.addLiveBroadcasAdministrator(liveBroadcasAdministrator);
    }


    @PatchMapping("/admin")
    public DTO<LiveBroadcasAdministrator> updateLiveAdmin(@RequestBody LiveBroadcasAdministrator liveBroadcasAdministrator) throws Exception {

        System.out.println(liveBroadcasAdministrator+"111");
        return liveBroadcasAdministratorService.updateLiveBroadcasAdministrator(liveBroadcasAdministrator);
    }

    @GetMapping("/getLiveAdminByPage")
    public DTO<LiveBroadcasAdministrator> ByPage(PageInfo pageInfo) throws Exception {
        DTO<LiveBroadcasAdministrator> dto = liveBroadcasAdministratorService.getLiveBroadcasAdministratorsByPage(pageInfo);
        return dto;
    }

    @DeleteMapping("/admin/{labano}")
    public DTO<LiveBroadcasAdministrator> deleteByKey(@PathVariable("labano") String labano) throws Exception {

        return liveBroadcasAdministratorService.deleteLiveBroadcasAdministrator(labano);
    }
}
